package com.fengmi.mapper;

import com.fengmi.entity.MallGoodsSku;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author 123
 * @Date 2022/2/10 11:16
 * @Version 1.0
 */


public interface GoodsSkuMapper {

    //通过商品的spu id获取商品sku信息
    @Select("select * from mall_goods_sku where spu_id = #{spuId}")
    public List<MallGoodsSku> findGoodsSkuBySpuId(String spuId);


    @Insert("\n" +
            "INSERT INTO `fengmi_mall`.`mall_goods_sku` \n" +
            "\t(\n" +
            "\t`sku_title`, \n" +
            "\t`sku_price`, \n" +
            "\t`sku_stock`, \n" +
            "\t`sku_low_stock`, \n" +
            "\t`sku_spec`, \n" +
            "\t`spu_id`\n" +
            "\t\n" +
            "\t)\n" +
            "\tVALUES\n" +
            "\t( \n" +
            "\t #{skuTitle},\n" +
            "\t #{skuPrice},\n" +
            "\t #{skuStock},\n" +
            "\t #{skuLowStock},\n" +
            "\t #{skuSpec},\n" +
            "\t #{spuId}\n" +
            "\t\n" +
            "\t);\n")
    public int insertSku(MallGoodsSku sku);
}
